﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace dzs.Web.supply
{
    public partial class BalanceDetail : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Session["login"] != null)
                {
                    DataSet ds = Session["login"] as DataSet;

                    int user_id = Convert.ToInt32(ds.Tables[0].Rows[0]["user_id"].ToString());

                    if (!string.IsNullOrEmpty(Request["projectId"]))
                    {
                        BindGvInventory(user_id, Request["projectId"]);
                        BindGvOutStorage(user_id, Request["projectId"]);
                        BindWaste(user_id, Request["projectId"]);


                        Maticsoft.Model.project p = new Maticsoft.BLL.project().GetModel(int.Parse(Request["projectId"]));

                        this.lbl_proid.Text = p.proid;
                        this.lbl_projectName.Text = p.projectName;
                    }

                   
                }
            }

        }

        private void BindGvInventory(int user_id, string projectId)
        {
            DataSet ds = new dzs.BLL.inventory().GetSumNumsProjectInventory(" uid="+user_id +" and projectId="+ projectId);

            this.gv_inventory.DataSource = ds;
            this.gv_inventory.DataBind();
        }

        private void BindGvOutStorage(int user_id, string projectId)
        {
            DataSet ds = new dzs.BLL.out_storage().GetSumNumsOutStorage(" uid=" + user_id + " and projectId=" + projectId);

            this.gv_outStore.DataSource = ds;
            this.gv_outStore.DataBind();
        }
        private void BindWaste(int user_id, string projectId)
        {
            DataSet ds = new dzs.BLL.instore().GetWaste(" uid=" + user_id + " and projectId=" + projectId);

            this.gv_feijiu.DataSource = ds;
            this.gv_feijiu.DataBind();
        
        }
    }
}